<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {

	var $data;

	public function __construct(){
		parent::__construct();

		$this->output->enable_profiler(false);


		$this->load->model('m_account');

		if(!$this->m_account->validate_cookie()){
			$this->session->set_flashdata('error', 'Anda tidak mempunyai akses ke halaman ini');
			header('location: '.site_url());
		}else{

			$this->data['cookie'] = $this->m_account->get_cookie();
		}
	}

	public function index(){

		$this->data['page']  = 'home';
		$this->data['title'] = 'Dashboard';
		$this->load->view('backend/dashboard', $this->data);

	}

	public function post(){

		$this->load->model('m_post');

		$this->data['post'] = $this->m_post->get_post();
		$this->data['page']  = 'post';
		$this->data['title'] = 'All Post';

		$this->load->view('backend/page/post', $this->data);
	}

	public function negara(){

		$this->load->model('negara');

		$this->data['negara'] = $this->negara->get_negara();
		$this->data['page']  = 'negara';
		$this->data['title'] = 'Daftar Negara';

		$this->load->view('backend/page/negara', $this->data);
	}

	public function siswa(){

		$this->load->model('siswa');		

		$this->data['siswa'] = $this->siswa->get_siswa();
		$this->data['page']  = 'siswa';
		$this->data['title'] = 'Daftar Siswa';

		$this->load->view('backend/page/siswa', $this->data);
	}

	public function logout(){

		$this->m_account->do_logout();
		header('location: '.site_url());
	}
	
}		